<template>
  <el-dialog
    title="未交作业列表"
    :visible.sync="visible"
    width="600px"
  >
    <el-table :data="assignments" style="width: 100%">
      <el-table-column prop="course_id" label="课程号" width="100"></el-table-column>
      <el-table-column prop="course_name" label="课程名称" width="150"></el-table-column>
      <el-table-column prop="assignment_title" label="作业标题"></el-table-column>
      <el-table-column prop="due_date" label="截止日期" width="180">
        <template #default="scope">
          {{ formatDate(scope.row.due_date) }}
        </template>
      </el-table-column>
    </el-table>
  </el-dialog>
</template>

<script>
export default {
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    assignments: {
      type: Array,
      default: () => []
    }
  },
  methods: {
    formatDate(dateStr) {
      return new Date(dateStr).toLocaleString('zh-CN', {
        year: 'numeric',
        month: '2-digit',
        day: '2-digit',
        hour: '2-digit',
        minute: '2-digit'
      });
    }
  }
}
</script>

<style scoped>
.el-dialog__body {
  padding: 20px;
}
</style>